package Threads;

import java.awt.List;
import java.io.File;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.net.UnknownHostException;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.util.concurrent.BlockingQueue;

public class S_TCP_Files implements Runnable {

	private int port;
	private String path;
	private Socket socket;
	private ArrayList<File> listoffiles;
	private 
	
	
	public S_TCP_Files(ArrayList<File> listoffiles, BlockingQueue<File> files edited) {
		// TODO Auto-generated constructor stub
		this.listoffiles = listoffiles;
	}
	
	@Override
	public void run() {
		// TODO Auto-generated method stub
		try {
			socket = new Socket(path,port);
			
		} catch (UnknownHostException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}

	private void firsttime() throws IOException {
		// TODO Auto-generated method stub
		File tmp = new File(System.getProperty("user.home")+"/MyDrop");
		String filesindir = null;
		String n_files[] ;
		if(tmp.exists()){
			filesindir = listpath(tmp);
			ObjectOutputStream sendfiles = new ObjectOutputStream(socket.getOutputStream());
			n_files=filesindir.split("\n");
			
		}
		
		
	}

	private String listpath(File tmp) {
		// TODO Auto-generated method stub
		String filesindir = "";
		for(File i : tmp.listFiles()){
			filesindir+=i.getPath();
			if(i.isDirectory())
				filesindir+=listpath(i);
		}
		return filesindir;
	}

}
